package com.example.springtransaction.controller;

import com.example.springtransaction.service.LogInfoService;
import com.example.springtransaction.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RequestMapping("/trans")
@RestController
public class TransactionalController {
    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private LogInfoService logInfoService;

    @Transactional(propagation = Propagation.REQUIRED)
    @RequestMapping("/registry")
    public String registry(String name, String password){
        logInfoService.insertLog(name,"注册");
        userInfoService.registryUser(name,password);

        return "注册成功";
    }
}
